package com.saihai.jiankang.ufTjglQxjrw.controller;

import com.saihai.common.annotation.Log;
import com.saihai.common.core.controller.BaseController;
import com.saihai.common.core.domain.AjaxResult;
import com.saihai.common.core.page.TableDataInfo;
import com.saihai.common.enums.BusinessType;
import com.saihai.common.utils.poi.ExcelUtil;
import com.saihai.jiankang.ufTjglQxjrw.domain.UfTjglQxjrw;
import com.saihai.jiankang.ufTjglQxjrw.service.IUfTjglQxjrwService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 体检子任务Controller
 * 
 * @author ruoyi
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/jiankang/ufTjglQxjrw")
public class UfTjglQxjrwController extends BaseController
{
    @Autowired
    private IUfTjglQxjrwService ufTjglQxjrwService;

    /**
     * 查询体检子任务列表
     */
    @GetMapping("/list")
    public TableDataInfo list(UfTjglQxjrw ufTjglQxjrw)
    {
        startPage();
        List<UfTjglQxjrw> list = ufTjglQxjrwService.selectUfTjglQxjrwList(ufTjglQxjrw);
        return getDataTable(list);
    }

    /**
     * 导出体检子任务列表
     */
    @Log(title = "体检子任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UfTjglQxjrw ufTjglQxjrw)
    {
        List<UfTjglQxjrw> list = ufTjglQxjrwService.selectUfTjglQxjrwList(ufTjglQxjrw);
        ExcelUtil<UfTjglQxjrw> util = new ExcelUtil<UfTjglQxjrw>(UfTjglQxjrw.class);
        util.exportExcel(response, list, "体检子任务数据");
    }

    /**
     * 获取体检子任务详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ufTjglQxjrwService.selectUfTjglQxjrwById(id));
    }

    /**
     * 新增体检子任务
     */
    @Log(title = "体检子任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UfTjglQxjrw ufTjglQxjrw)
    {
        return toAjax(ufTjglQxjrwService.insertUfTjglQxjrw(ufTjglQxjrw));
    }

    /**
     * 修改体检子任务
     */
    @Log(title = "体检子任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UfTjglQxjrw ufTjglQxjrw)
    {
        return toAjax(ufTjglQxjrwService.updateUfTjglQxjrw(ufTjglQxjrw));
    }

    /**
     * 删除体检子任务
     */
    @Log(title = "体检子任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ufTjglQxjrwService.deleteUfTjglQxjrwByIds(ids));
    }
}
